using IrisGenerator.Common.Core;
using System.ComponentModel;
using IrisGenerator.Common.DataTypes.Rules;
using System;
using IrisGenerator.Framework.RuleEngine;
using IrisGenerator.Framework.Events;
using IrisGenerator.Common.Tools;
namespace IrisGenerator.Common.DataTypes
{


    public partial class MetatypeEquivalences : BindableObject<MetatypeEquivalences>, IRuleable<MetatypeEquivalences>, INotifyPropertyChanged
    {

        #region Properties

        public bool IsDirty { get; private set; }

        #endregion

        #region Events

        public event EventHandler<BaseEventArgs<MetatypeEquivalences>> Inserting;
        public event EventHandler<BaseEventArgs<MetatypeEquivalences>> Inserted;
        public event EventHandler<BaseEventArgs<MetatypeEquivalences>> Deleting;
        public event PropertyChangedEventHandler PropertyChanged;

        
        protected void OnDeleting(BaseEventArgs<MetatypeEquivalences> e)
        {
            if (Deleting != null)
                Deleting(this, e);
        }
        protected void OnInserting(BaseEventArgs<MetatypeEquivalences> e)
        {
            if (Inserting != null)
                Inserting(this, e);
        }
        protected void OnInserted(BaseEventArgs<MetatypeEquivalences> e)
        {
            if (Inserted != null)
                Inserted(this, e);
        }
        protected void OnPropertyChanged(string PropertyName)
        {
            this.IsDirty = true;

            if (this.PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(PropertyName));
        }

        #endregion

        #region ctor

        public MetatypeEquivalences()
            : base()
        {
            this.Rules=new MetatypeEquivalencesRule(this);
        }

        #endregion

        #region IRuleable Members

        public RuleBase<MetatypeEquivalences> Rules { get; private set; }

        public MetatypeEquivalencesRule ObjectRules
        {
            get
            {
                return this.Rules as MetatypeEquivalencesRule;
            }
        }

        #endregion

        #region Overrides

        public override bool Delete()
        {
            return this.Delete(false);
        }

        #endregion

        public static void CleanLinks()
        {
            IrisGenerator.Dal.MetatypeEquivalences dbo = null;
            try
            {

                dbo = new IrisGenerator.Dal.MetatypeEquivalences();
                dbo.CleanLinks();
            }
            catch (System.Exception)
            {
                throw;
            }
            finally
            {
                if ((dbo != null))
                {
                    dbo.Dispose();
                }
            }
        }

        #region Strapping Properties (Used for binding)

        public string MetatypeName
        {
            get
            {
                if (this.Metatype != null)
                    return this.Metatype.MetCode;
                return string.Empty;
            }
        }

        #endregion

        
    }
}
